﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WinAutomator.Library;
using WinAutomator.Library.InOut;
using WinAutomator.Library.MainType;

namespace WinAutomator.Plugin.BuildIns
{
    public class WASetString : IProcess
    {
        public String Message { get; set; }

        String _result = null;
        IConnector _nextConnector;
        List<VirtualConnector> _vconnector = new List<VirtualConnector>();

        public WASetString()
        {
            In = new Connector<WinAutomator.Library.MainType.WAAllType>(WAInOut.In, this);
            Out = new Connector<String>(WAInOut.Out, this);
            Out.GetProcessData = GetString;

            VIn = new VirtualConnector(WAInOut.In);
            VIn.AddConnector(In);
            _vconnector.Add(VIn);

            VOut = new VirtualConnector(WAInOut.Out);
            VOut.AddConnector(Out);
            _vconnector.Add(VOut);

            Message = String.Empty;
        }

        public VirtualConnector VIn { get; protected set; }
        public VirtualConnector VOut { get; protected set; }



        public IConnector Execute()
        {
            _nextConnector = (IConnector)Out;

            return _nextConnector;
        }

        public string getResult()
        {
            return Message;
        }

        public List<Type> getAcceptedType()
        {
            List<Type> type = new List<Type>() {typeof(object)};
            
            return type;
        }

        public String GetString()
        {
            return getResult();
        }

        private Connector<WinAutomator.Library.MainType.WAAllType> In { get; set; }
        private Connector<String> Out { get; set; }

        #region IProcess Membres



        public List<VirtualConnector> getVirtualConnectors()
        {
            return _vconnector;
        }


        public List<VirtualConnector> getVirtualConnectors(WAInOut type)
        {
            List<VirtualConnector> tmp = new List<VirtualConnector>();

            foreach (VirtualConnector v in _vconnector)
                if (v.VirtualConnectorType == type)
                    tmp.Add(v);
            
            return tmp;
        }

        #endregion
    }
}
